package com.yunfu.controller;

import com.yunfu.entity.User;
import com.yunfu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/findAll")
    public ModelAndView findAll(){
        // 调用service查询
        List<User> list = userService.findAll();
        // 返回
        ModelAndView mv = new ModelAndView();
        mv.setViewName("list");
        mv.addObject("list",list);
        return mv;
    }
}
